package com.cheng.io.output;

import com.cheng.io.entity.Student;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * transient关键字，序列化时忽略当前属性
 */
public class ObjectOutputStreamTest04 {
    public static void main(String[] args) {
        try (
                ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("io/resources/student2"));
        ) {
            objectOutputStream.writeObject(new Student("zhangsan",66));
            objectOutputStream.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
